﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;

using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;

namespace GUI
{
    public partial class FrmMainContromller : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private FrmMainGuest frmMainGuest;
        public FrmMainContromller(FrmMainGuest frmMainGuest)
        {
            InitializeComponent();
            InitSkinGallery();
            this.frmMainGuest = frmMainGuest;
        }
        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }

        private void btnNSX_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is Catalog.FrmNSX) { x.Activate(); return; }
            var frm = new Catalog.FrmNSX() { MdiParent = this };
            frm.Show();
        }

        private void btnLoaihang_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is Catalog.FrmLoaihang) { x.Activate(); return; }
            var frm = new Catalog.FrmLoaihang() { MdiParent = this };
            frm.Show();
        }

        private void btnDonvitinh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is Catalog.FrmDonvitinh) { x.Activate(); return; }
            var frm = new Catalog.FrmDonvitinh() { MdiParent = this };
            frm.Show();
        }

        private void btnSanpham_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is FrmSanpham) { x.Activate(); return; }
            var frm = new FrmSanpham() { MdiParent = this };
            frm.Show();   
        }

        private void FrmMainContromller_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmMainGuest.Show();
            this.Dispose();
        }

        private void btnComeback_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmMainContromller_FormClosed(null, null);
        }

        private void btnCloseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) x.Close();
        }

    }
}